﻿using System.Windows;
using VSCleaner.ViewModel;
using System.Windows.Controls;

namespace VSCleaner
{
    /// <summary>
    /// MainWindow View
    /// </summary>
    public partial class MainWindow : Window
    {
        /// <summary>
        /// ViewModel Instance
        /// </summary>
        private MainWindowViewModel dataContext;

        /// <summary>
        /// Default Constructor
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
            dataContext = new MainWindowViewModel();
            DataContext = dataContext;
        }

        /// <summary>
        /// Removes an Item from Folder List
        /// </summary>
        /// <param name="sender">object</param>
        /// <param name="e">RoutedEventArgs</param>
        private void RemoveClick(object sender, RoutedEventArgs e)
        {
            var button = sender as Button;
            var path = button.Tag.ToString();

            if (dataContext.FolderList.Contains(path))
            {
                dataContext.FolderList.Remove(path);
                dataContext.CheckIfCleanAvailable();
                dataContext.SaveInSettings();
            }
        }
    }
}
